package com.zsq.thread.test2;

/**
 * @author : zhang sq
 * @date : 2019/12/25 21:36
 **/
// 同步方法和不同步方法能否可以同时调用?   可以的
public class Sync4 {

    public static void main(String[] args) {
        Sync4 sync4=new Sync4();
        new Thread(sync4::m1,"T1").start();
        new Thread(sync4::m2,"T2").start();
    }


    private synchronized void m1() {
        System.out.println(Thread.currentThread().getName() + "m1 Start");
        try {
            Thread.sleep(8000);
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName() + "m1 End");
    }

    private  void m2() {
        System.out.println(Thread.currentThread().getName() + "m2 Start");
        try {
            Thread.sleep(5000);
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName() + "m2 End");
    }
}
